// 二叉搜索树  
var lowestCommonAncestor = function(root, p, q) {
  let ancestor = root;
  while (true) {
    if (p.val < root.val && q.val < root.val) {
      root = root.left;
    } else if (p.val > root.val && q.val > root.val) {
      root = root.right;
    } else {
      ancestor = root;  
      break;
    }
  }
  return ancestor;
};
